<template>
  <div>
    <div class="block">
      <span class="demonstration">默认</span>

      <el-date-picker
        v-model="value1"
        type="datetimerange"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期">
      </el-date-picker>
    </div>
    <!-- <div class="block">
      <span class="demonstration">带快捷选项</span>
      <el-date-picker
        v-model="value2"
        type="datetimerange"
        :picker-options="pickerOptions"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        align="right">
      </el-date-picker>
    </div> -->
  </div>
</template>

<script>



  export default {
    data() {
      const start = new Date(new Date(new Date().toLocaleDateString()).getTime());
      console.log(start); //Mon Dec 04 2017 00:00:00 GMT+0800 (中国标准时间)
      const end = new Date(new Date(new Date().toLocaleDateString()).getTime()+24*60*60*1000-1);
      console.log(end); //Mon Dec 04 2017 23:59:59 GMT+0800 (中国标准时间)
      // // 获取当前时间
      // var dateTime = new Date();
      // // 设置时间 +1 天
      // dateTime = dateTime.setDate(dateTime.getDate()+1);
      // // 设置时间
      // dateTime = new Date(dateTime);
      return {
        pickerOptions: {
          shortcuts: [{
            text: '最近一周',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近一个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近三个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit('pick', [start, end]);
            }
          }]
        },
        value1: [start, end],
        value2: ''
      };
    },
    mounted() {
      console.log(this.value1, 'vaue')
    },
  };
</script>
